# this is calling from the /evx/arch/x86/Makefile and we need to 
# compile these assembly codes those there isn't a rule to compile 
# it. 

# 's' is the asm object
obj-s = boot$(BITS).S.o.bin setup$(BITS).S.o.bin 

all: 	Image

%.S.o: 		%.S
	@$(CPP)	$*.S | $(AS) --32 -o $*.S.o.l 
	@echo "AS                $*.S.o.l"
	@$(LD) 	$*.S.o.l -o $*.S.o -T boot.lds 
	@echo "LD                $*.S.o"

%.S.o.bin:	%.S.o
	@objcopy -S -j .text -O binary $*.S.o $*.S.o.bin
	@echo "OBJCOPY           $*.S.o.bin"


Image:	$(obj-s) 
	@dd if=/dev/zero of=Image bs=1048576 count=64 >& /dev/zero 
	@dd if=boot$(BITS).S.o.bin of=Image conv=notrunc >& /dev/zero 
	@dd if=setup$(BITS).S.o.bin of=Image conv=notrunc bs=512 seek=1 >& /dev/zero 
	@dd if=$(PWD)/arch/x86/vmevx.bin of=Image conv=notrunc bs=512 seek=2 >& /dev/zero 
	@echo "MKIMG             Image"


.PHONY clean:
	@rm Image -f  
	@rm $*.S.o *.bin *.S.o.l -f 
	@echo "CLEAN             Image"

